import './assets/main.css'

import { createApp } from 'vue'
import { createPinia } from 'pinia'

// 引入 Arco Design
import ArcoVue from '@arco-design/web-vue'
// 引入 Arco Design 样式
import '@arco-design/web-vue/dist/arco.css'
// 引入 Arco Design 图标
import ArcoVueIcon from '@arco-design/web-vue/es/icon'

import App from './App.vue'
import router from './router'
import { useUserStore } from './stores/user'

const app = createApp(App)
const pinia = createPinia()

app.use(pinia)
app.use(router)
// 使用 Arco Design
app.use(ArcoVue)
// 使用 Arco Design 图标
app.use(ArcoVueIcon)

// 初始化应用前，先初始化用户状态
const initApp = async () => {
  // 初始化用户状态
  const userStore = useUserStore()
  await userStore.initialize()
  
  // 挂载应用
  app.mount('#app')
}

initApp()
